#include "ExplosionGroup.h"
#include "PlayState.h"

CExplosionGroup::CExplosionGroup(D3DXVECTOR2 pos, int id, int typeID, float time, int type):
CMoveableObject(pos, id, typeID)
{
	m_nCount = 0;
	m_fTimeExplosion = time;
	m_nTypeExplosion = type;
	m_fTimeChange = 0.0f;
}

CExplosionGroup::~CExplosionGroup()
{
	
}

void CExplosionGroup::Update(float timeFrame)
{
	if (!m_bIsLive)
		return;
	if (m_nCount >= m_aPos.size())
	{
		this->Kill();
		return;
	}
	if (m_fTimeChange > 0)
	{
		m_fTimeChange -= timeFrame;
	}
	else
	{
		m_fTimeChange = TIME_CHANGE;
		CExplosion* ex = new CExplosion(m_aPos[m_nCount], 0, m_nTypeExplosion, false, m_fTimeExplosion);
		CPlayState::s_objsOutSideQuadTree.push_back(ex);
		m_nCount++;
	}
}

void CExplosionGroup::SetArrayPos(vector<D3DXVECTOR2 > aPos)
{
	this->m_aPos = aPos;
}